<script setup lang="ts">
  import { ref } from 'vue';
  import { getToken } from '@/utils/auth';

  const token = getToken();
  const message = ref<string>('123');

  function click() {
    const data = {
      clientid: 'sn-XN013496017',
      username: 'XN013496017',
      password: '2ed639f4b691f76dd2006680c20e93f2',
    };

    fetch('http://sit-cn.hero-ee.com:8002/api/emqx/hook/auth', {
      method: 'POST',
      body: JSON.stringify(data),
      headers: {
        'content-type': 'application/json;charset=UTF-8',
        Authorization: token,
      },
    })
      .then(function (response) {
        return response.json();
      })
      .then(function (json) {
        message.value = json;
      });
  }
</script>

<template>
  <div>
    <div @click="click">{{ message }}</div>
  </div>
</template>

<style scoped lang="less"></style>
